package com.jlastu.dlxy_androidapp.view.main;

import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.jlastu.dlxy_androidapp.R;

public class SelectGoodsActivity extends AppCompatActivity {

    private SelectFragment mSelectFragment;

    private FragmentManager mFragmentManager;

    private Fragment mFragment;
    @Override
    public void onConfigurationChanged(android.content.res.Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        // 检查屏幕方向是否为横屏
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            Log.d("Orientation", "Landscape detected");

            // 创建并启动新的Activity
            Intent intent = new Intent(this, LandscapeActivity.class);
            startActivity(intent);

            // 可选：关闭当前Activity
            finish();
        }
    }
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_goods);
        initFragment();
        mFragmentManager.beginTransaction().replace(R.id.fragment_content,mSelectFragment).commitAllowingStateLoss();
        mFragment = mSelectFragment;


    }

    private void initFragment() {
        mFragmentManager = getSupportFragmentManager();
        mSelectFragment = new SelectFragment();
    }
}
